﻿<Window x:Class="LockCrypt.WinOptions"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:props="clr-namespace:LockCrypt.Properties"
    xmlns:loc="clr-namespace:LockCrypt"
    xmlns:lex="http://schemas.root-project.org/xaml/presentation"
    xmlns:conv="clr-namespace:LockCrypt.Converters"
    xmlns:l49ui="clr-namespace:Lime49.UI;assembly=Lime49"
    xmlns:l49="clr-namespace:Lime49;assembly=Lime49"
    l49:WindowService.EscapeClosesWindow="True"
    WindowStartupLocation="CenterOwner"
    Title="{lex:LocText LockCrypt.Core:Strings:Options}"
    Height="500" MinHeight="300" Width="430" MinWidth="200"
    Style="{StaticResource {x:Type Window}}" Icon="/LockCrypt;component/Resources/LockCrypt.ico">
    <Window.Resources>
        <props:Settings x:Key="settings" />
        <conv:StringToKeyGestureConverter x:Key="StringToKeyGestureConverter"/>
    </Window.Resources>
    <Window.CommandBindings>
        <CommandBinding Command="ApplicationCommands.Close" Executed="CloseWindow"/>
        <CommandBinding Command="ApplicationCommands.Save" Executed="Save"/>
    </Window.CommandBindings>
    <DockPanel Margin="6" LastChildFill="True">
        <StackPanel DockPanel.Dock="Bottom" Orientation="Horizontal" HorizontalAlignment="Right">
            <Button Command="ApplicationCommands.Save" IsDefault="True" VerticalAlignment="Center" MinWidth="70" Content="{lex:LocText LockCrypt.Core:Strings:Save}" />
            <Button Command="ApplicationCommands.Close" IsCancel="True" VerticalAlignment="Center" MinWidth="70" Content="{lex:LocText LockCrypt.Core:Strings:Cancel}" />
        </StackPanel>
        <TabControl DockPanel.Dock="Top" x:Name="tbcTabs" DataContext="{StaticResource settings}" Grid.IsSharedSizeScope="True">
            <TabItem x:Name="tabPreferences">
                <TabItem.Header>
                    <StackPanel Orientation="Horizontal">
                        <Image Source="pack://application:,,,/Resources/Images/settings_16.png" Width="16" Margin="2,0"/>
                        <TextBlock Text="{lex:LocText LockCrypt.Core:Strings:Preferences}"/>
                    </StackPanel>
                </TabItem.Header>
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="Auto"/>
                    </Grid.RowDefinitions>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="Auto" SharedSizeGroup="labels"/>
                        <ColumnDefinition Width="*"/>
                    </Grid.ColumnDefinitions>
                    
                    <CheckBox Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="2" x:Name="chkAutoStart" Content="{lex:LocText LockCrypt.Core:Strings:StartWithWindows}" IsChecked="{Binding Default.AutoStart,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" Margin="5,2"/>
                    
                    <CheckBox Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2" x:Name="chkMinimizeToTray" Content="{lex:LocText LockCrypt.Core:Strings:MinimizeToSystemTray}" IsChecked="{Binding Default.MinimizeToTray,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" Margin="5,2"/>
                    
                    <CheckBox Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="2" x:Name="chkAutoRelock" IsChecked="{Binding Default.AutoLock,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" Margin="5,2">
                        <CheckBox.Content>
                            <StackPanel Orientation="Horizontal" VerticalAlignment="Center">
                                <TextBlock Text="{lex:LocText LockCrypt.Core:Strings:AutoLockDesc}" VerticalAlignment="Center"/>
                                <l49ui:MaskedTextBox x:Name="txtAutoLockDelay" Text="{Binding Default.AutoLockDelay,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" Width="40" Type="Digits" MaxLength="4" Margin="2,0"
                                         IsEnabled="{Binding Default.AutoLock,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"/>
                                <TextBlock Text="{lex:LocText LockCrypt.Core:Strings:Seconds}" VerticalAlignment="Center"/>
                            </StackPanel>
                        </CheckBox.Content>
                    </CheckBox>

                    <Label Grid.Row="3" Grid.Column="0" Content="{lex:LocText LockCrypt.Core:Strings:WhenLockingAction}"/>
                    <ComboBox Grid.Row="3" Grid.Column="1" x:Name="cboCloseAction" Background="White" SelectedValuePath="Key" DisplayMemberPath="Value"  SelectedValue="{Binding Default.CloseOnLock,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"/>
                    
                    <Label Grid.Row="4" Grid.Column="0" Content="{lex:LocText LockCrypt.Core:Strings:SearchDelay}"/>
                    <l49ui:MaskedTextBox Grid.Row="4" Grid.Column="1" x:Name="txtSearchDelay" Text="{Binding Default.SearchDelay,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" Width="40" Type="Digits" MaxLength="4" HorizontalAlignment="Left" VerticalAlignment="Center" VerticalContentAlignment="Bottom" />
                    
                    <Label Grid.Row="5" Grid.Column="0" Content="{lex:LocText LockCrypt.Core:Strings:Language}"/>
                    <ComboBox Grid.Row="5" Grid.Column="1" x:Name="cboLanguage" ItemTemplate="{StaticResource LanguageListItem}" Background="White" SelectedValuePath="Key" SelectedValue="{Binding Default.Language,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"/>
                </Grid>
            </TabItem>
            <TabItem x:Name="tabDatabase">
                <TabItem.Header>
                    <StackPanel Orientation="Horizontal">
                        <Image Source="pack://application:,,,/Resources/Images/database_16.png" Width="16" Margin="2,0"/>
                        <TextBlock Text="{lex:LocText LockCrypt.Core:Strings:Database}"/>
                    </StackPanel>
                </TabItem.Header>
                <StackPanel>
                    <CheckBox x:Name="chkAutoOpen" Content="{lex:LocText LockCrypt.Core:Strings:OpenPrefferedOnStartup}" IsChecked="{Binding Default.AutoOpenOnStartup,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"
                              Margin="5,2"/>
                    <GroupBox Header="{lex:LocText LockCrypt.Core:Strings:DatabaseLocation}" IsEnabled="{Binding Default.AutoOpenOnStartup}">
                        <Grid>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="Auto"/>
                                <RowDefinition Height="Auto"/>
                                <RowDefinition Height="Auto"/>
                            </Grid.RowDefinitions>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="Auto" SharedSizeGroup="labels"/>
                                <ColumnDefinition Width="*"/>
                            </Grid.ColumnDefinitions>
                            
                            <TextBlock Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="2" TextWrapping="Wrap" Style="{StaticResource PaddedTextBlock}" Text="{lex:LocText LockCrypt.Core:Strings:DbModeDesc}"/>
                            <loc:DatabaseSelector x:Name="dbSelector" Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2"
                                                  DatabaseMode="{Binding Default.DatabaseMode,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"
                                                  ConnectionString="{Binding Default.DatabaseConnectionString,Mode=OneWay,UpdateSourceTrigger=PropertyChanged}"
                                                  ShowEncryption="False" IsSaveDialog="False" AutoUpdateDatabasePath="False" />
                            <Label Grid.Row="2" Grid.Column="0" Content="{lex:LocText LockCrypt.Core:Strings:EncryptionAlgorithm}"/>
                            <ComboBox Grid.Row="2" Grid.Column="1" x:Name="cboEncryption" DisplayMemberPath="Value" SelectedValuePath="Key"
                                    SelectedValue="{Binding Default.EncryptionAlgorithm,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" />
                        </Grid>
                    </GroupBox>
                </StackPanel>
            </TabItem>
            <TabItem>
                <TabItem.Header>
                    <StackPanel Orientation="Horizontal">
                        <Image Source="pack://application:,,,/Resources/Images/keyboard_16.png" Width="16" Margin="2,0"/>
                        <TextBlock Text="{lex:LocText LockCrypt.Core:Strings:ShortcutKeys}"/>
                    </StackPanel>
                </TabItem.Header>
                <StackPanel>
                    <GroupBox Header="{lex:LocText LockCrypt.Core:Strings:AutoType}">
                        <loc:HotkeyMapper x:Name="autotypeHotkeyMapper" ShortcutKey="{Binding Default.AutoTypeHotkey,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged,Converter={StaticResource StringToKeyGestureConverter}}"/>
                    </GroupBox>
                    <GroupBox Header="{lex:LocText LockCrypt.Core:Strings:Relock}">
                        <loc:HotkeyMapper x:Name="relockHotkeyMapper" ShortcutKey="{Binding Default.RelockHotkey,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged,Converter={StaticResource StringToKeyGestureConverter}}"/>
                    </GroupBox>
                </StackPanel>
            </TabItem>
            <TabItem>
                <TabItem.Header>
                    <StackPanel Orientation="Horizontal">
                        <Image Source="pack://application:,,,/Resources/Images/firefox_16.png" Width="16" Margin="2,0"/>
                        <TextBlock Text="{lex:LocText LockCrypt.Core:Strings:FirefoxExtension}"/>
                    </StackPanel>
                </TabItem.Header>
                <StackPanel>
                    <Image Source="pack://application:,,,/Resources/Images/lockcrypt-firefox.png" HorizontalAlignment="Center" Stretch="None"/>
                    <TextBlock Text="{lex:LocText LockCrypt.Core:Strings:FirefoxExtensionDesc}" TextWrapping="Wrap" TextTrimming="CharacterEllipsis" />
                    <CheckBox x:Name="chkFirefox" Content="{lex:LocText LockCrypt.Core:Strings:EnableFirefoxPlugin}" IsChecked="{Binding Default.FirefoxEnabled,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" Margin="2"/>
                    <l49ui:Hyperlink Text="{lex:LocText LockCrypt.Core:Strings:FirefoxUserGuide}" NavigateUrl="http://wiki.lime49.com/index.php?title=Firefox_Extension_%28LockCrypt%29"/>
                    <l49ui:Hyperlink Text="{lex:LocText LockCrypt.Core:Strings:FireforMozillaLink}" NavigateUrl="https://addons.mozilla.org/en-US/firefox/addon/8970"/>
                </StackPanel>
            </TabItem>
            <TabItem>
                <TabItem.Header>
                    <StackPanel Orientation="Horizontal">
                        <Image Source="pack://application:,,,/Resources/Images/clipboard_16.png" Width="16" Margin="2,0"/>
                        <TextBlock Text="{lex:LocText LockCrypt.Core:Strings:SecureClipboard}"/>
                    </StackPanel>
                </TabItem.Header>
                <Grid Margin="2">
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="Auto"/>
                    </Grid.RowDefinitions>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="Auto"/>
                        <ColumnDefinition Width="Auto"/>
                        <ColumnDefinition Width="Auto"/>
                        <ColumnDefinition Width="*"/>
                    </Grid.ColumnDefinitions>
                    <TextBlock Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="4" Text="{lex:LocText LockCrypt.Core:Strings:SecureClipboardDesc}" VerticalAlignment="Center" TextWrapping="Wrap" TextTrimming="CharacterEllipsis"/>
                    <CheckBox Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="4" x:Name="chkSecureClipEnabled" IsChecked="{Binding Default.SecureClip,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" Margin="5,2" Content="{lex:LocText LockCrypt.Core:Strings:UseSecureClipboard}"/>
                        
                    <TextBlock Grid.Row="2" Grid.Column="0" Text="{lex:LocText LockCrypt.Core:Strings:ClearClipboardAfter}" IsEnabled="{Binding Default.SecureClip,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" VerticalAlignment="Center"/>
                    <l49ui:MaskedTextBox Grid.Row="2" Grid.Column="1" x:Name="txtSecureClipDelay" Text="{Binding Default.SecureClipDelay,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" Width="30" Type="Digits" MaxLength="4" Margin="2,0"
                                 IsEnabled="{Binding Default.SecureClip,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"/>
                    <TextBlock Grid.Row="2" Grid.Column="2" Text="{lex:LocText LockCrypt.Core:Strings:Seconds}" IsEnabled="{Binding Default.SecureClip,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" VerticalAlignment="Center"/>
                </Grid >
            </TabItem>
        </TabControl>
    </DockPanel>
</Window>
